package com.bwf.bytes;

import java.io.*;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/17 14:49
 * @Copyright 博为峰
 */
public class FileInOutputStreamDemo {
    public static void main(String[] args) throws IOException {
//        m1();
        //读
//        m2();
    }

    private static void m2() throws IOException {
        FileInputStream inputStream = new FileInputStream("C:\\Users\\admin\\Desktop\\22\\shell-chrome.zip");
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);

        //写
        FileOutputStream outputStream = new FileOutputStream("C:\\Users\\admin\\Desktop\\22\\copy\\shell-chrome3.zip");
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);

        int count = 0;
        while ((count = bufferedInputStream.read()) != -1) {
            bufferedOutputStream.write(count);
        }
    }

    private static void m1() {
        byte[] bytes = new byte[1024];
        try (FileInputStream inputStream = new FileInputStream("C:\\Users\\admin\\Desktop\\22\\shell-chrome.zip");
             FileOutputStream outputStream = new FileOutputStream("C:\\Users\\admin\\Desktop\\22\\copy\\shell-chrome.zip");
        ) {
            int count = 0;
            while ((count = inputStream.read(bytes)) != -1) {
                outputStream.write(bytes);
            }
        } catch (IOException e) {

        }
    }
}
